package com.example.demo.demos.web;


import com.example.demo.demos.web.Annotation.ValidateDto;
import com.example.demo.demos.web.Resoult.ErrorResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {
//
//    /**
//     * 登陆方法( 用不到了)
//     * @return
//     */
//    @RequestMapping("/login")
//    public String login() {
//        System.out.println("执行登陆方法");
//        return  "redirect:main.html";
//    }


    /**
     * 登陆成功页面
     * @return
     */
    @ValidateDto
    @RequestMapping("/test")
    public ResponseEntity<ErrorResponse> test(UserDto dto) {
        return  ResponseEntity.status(HttpStatus.OK)
                .body(new ErrorResponse(HttpStatus.OK.value(),"请求成功"));
    }


    /**
     * 登陆成功页面
     * @return
     */
    @ValidateDto
    @RequestMapping("/toMain")
    public String toMain(UserDto dto) {
        return  "redirect:main.html";
    }


    /**
     * 登陆失败页面
     * @return
     */
    @RequestMapping("/toError")
    public String toError() {
        return  "redirect:error.html";
    }


}
